package demo1;

import java.util.Arrays;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    public int maxConsecutive(int bottom, int top, int[] special) {
        Arrays.sort(special);//n log n
        int max = 0;
        for (int i = 0; i < special.length - 1; i++) {
            max = Math.max(max, special[i + 1] - special[i] - 1);//记录中间的特殊楼层
        }
        //处理边界
        if (bottom < special[0]) {
            max = Math.max(max, special[0] - bottom);
        }
        if (top > special[special.length - 1]) {
            max = Math.max(max, top - special[special.length - 1]);
        }
        return max;
    }
}
